<?
define('TEMPLATES', '../templates/');
define('JS','../js/');
define('IMAGES','../images/');
define('CSS','../css/');
define('OBJETOS','../objetos/');
define('NEGOCIOS','../negocio/');
define('EXTENSION','.phtml');
session_start();
function __autoload($class_name){
  require_once $class_name . '.php';
}

class Session extends FuncionComun
{
	var $conexion;
	var $vars;
	var $generador_xhtml;
	
	function Session($vars)
	{
		$this->conexion= new ConexionDB();
		$this->vars=$vars;
		$this->generador_xhtml=new GeneradorXHTML();
	}
	
	function login(){
	$this->generador_xhtml->mostrarTpl("",array("tpl"=>"Sesion","header"=>"headerSesion","footer"=>"footerSesion","css"=>"Sesion","js"=>"Sesion"));
	}
	
	function validar()
	{
		echo $this->verificarLogin("empleado",utf8_decode($this->vars["user"]),utf8_decode($this->vars["pass"]));	
	}
	
	function logOut()
	{
		$this->sesion(false,"LOGIN");
		$this->redireccionar("TransaccionHotel.php");
		
	}
	
	function isLoginDisponible()
	{
		$this->conexion->realizarConsulta("select * from persona where login_persona='".$this->vars["login"]."'");
		$res=$this->conexion->getResultadosConsulta();
		if($res[0])
			echo "false";
		else
			echo "true";
	}
}

$metodo=current($_POST)?current($_POST):"login";
$vars=array_slice($_POST,1);
if($_GET)
{
	$metodo=current($_GET)?current($_GET):"login";
	$vars=array_slice($_GET,1);
}
call_user_func(array(new Session($vars),$metodo));

?>